package com.link.base.base.currencyparams.controller;


import com.link.base.base.currencyparams.model.CurrencyParams;
import com.link.base.base.currencyparams.service.CurrencyParamsService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.ServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
 * Copyright  hande Company. All Rights Reserved.
 *
 * @author  unknwon
 * @date:   2018/11/9 15:31
 * @version 1.0
 */

@Controller
@RequestMapping("/link/currencyParams")
public class CurrencyParamsController extends BasicController<CurrencyParams> {

    @Resource
    private CurrencyParamsService currencyParamsService;

    @Override
    public BasicService<CurrencyParams> getBasicService() throws Exception {
        return currencyParamsService;
    }

    @Override
    public void beforInsert(CurrencyParams entity, HttpServletRequest request) throws Exception {
        if (StringUtils.isEmpty(entity.getCurrencyName())
                || StringUtils.isEmpty(entity.getCurrencyCode())
                || StringUtils.isEmpty(entity.getCurrencyMark())
                || null == entity.getAllAddrId()
                || StringUtils.isEmpty(entity.getStatus())) {
            throw new ServiceException("PUBLIC-015");
        }
    }

    @Override
    public void beforUpdate(CurrencyParams entity, HttpServletRequest request) throws Exception {
        if (StringUtils.isEmpty(entity.getCurrencyName())
                || StringUtils.isEmpty(entity.getCurrencyCode())
                || StringUtils.isEmpty(entity.getCurrencyMark())
                || null == entity.getAllAddrId()
                || StringUtils.isEmpty(entity.getStatus())) {
            throw new ServiceException("PUBLIC-015");
        }
    }
}
